//***抽象类的学习***

abstract class Shape {
    String color;

    public Shape(String color) {
        this.color = color;
    }

    public abstract double getArea();

    public void showColor() {
        System.out.println("这个形状的颜色是：" + color);
    }
}

class Circle extends Shape {
    double radius;

    public Circle(String color, double radius) {
        super(color);
        this.radius = radius;
    }

    @Override
    public double getArea() {
        return Math.PI * radius * radius;
    }
}

class Rectangle extends Shape {
    double length;
    double width;

    public Rectangle(String color, double length, double width) {
        super(color);
        this.length = length;
        this.width = width;
    }

    @Override
    public double getArea() {
        return length * width;
    }
}

public class abstrac {
    public static void main(String[] args) {
        Circle circle = new Circle("红色", 5);
        circle.showColor();
        System.out.println("圆形的面积是：" + circle.getArea());

        Rectangle rectangle = new Rectangle("蓝色", 4, 6);
        rectangle.showColor();
        System.out.println("矩形的面积是：" + rectangle.getArea());
    }
}
